<?php

namespace app\common\job;

use app\admin\model\ExternalPlatform;
use app\index\service\AxbResultCallbackService;
use app\index\service\ConsultingAxbResultCallbackService;
use think\queue\Job;

/**
 * AXB通话结果处理
 * Class ConsultingAxbResult
 * @package app\common\job
 */
class ConsultingAxbResult
{
    /**
     * fire是消息队列默认调用的方法
     * @param Job $job 当前的任务对象
     * @param array|mixed $data 发布任务时自定义的数据
     */
    public function fire(Job $job, $data)
    {
        try {
            $this->getConsultingAxbResultCallbackService()->handle($data['params'] ?? []);
        } finally {
            $job->delete();
        }

    }


    private function getConsultingAxbResultCallbackService(): ConsultingAxbResultCallbackService
    {
        return app(ConsultingAxbResultCallbackService::class);
    }
}
